package com.hopu.blb_erp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hopu.blb_erp.entity.PageEntity;
import com.hopu.blb_erp.entity.TShipping;
import com.hopu.blb_erp.entity.TWarehouse;
import com.hopu.blb_erp.mapper.ShippingMapper;
import com.hopu.blb_erp.mapper.WarehouseMapper;
import com.hopu.blb_erp.service.ShippingService;
import com.hopu.blb_erp.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShippingServiceImpl extends ServiceImpl<ShippingMapper, TShipping> implements ShippingService {

    @Autowired
    private ShippingMapper shippingMapper;

    @Override
    public Integer findCount(String shippingNumber) {
        return shippingMapper.selectCount(shippingNumber);
    }

    @Override
    public PageEntity<TShipping> findPage(Integer current, Integer pageSize,String shippingNumber) {
        Integer count = shippingMapper.selectCount(shippingNumber);
        List<TShipping> warehouses = shippingMapper.selectPage((current - 1) * pageSize, pageSize,shippingNumber);
        PageEntity<TShipping> shippingPageEntity = new PageEntity<>();
        shippingPageEntity.setData(warehouses);
        shippingPageEntity.setCurrent(current);
        shippingPageEntity.setCount(count);
        return shippingPageEntity;
    }

    @Override
    public TShipping findByNumber(String shippingNumber) {
        return shippingMapper.selectByNumber(shippingNumber);
    }
}
